<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Blog Management System</title>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
            border: 2px solid black;
            border-top: 2px;
            border-left: 2px;
            border-right: 2px;
            border-bottom: 1px solid black;
        }
        th,
        td {
            padding: 15px;
            text-align: center;
            font-size: 25px;
            color: red;
            border-bottom: 1px solid black;
        }
        th {
            color: red;
            border-bottom: 1px solid black;
        }
        tr:nth-child(even) {
            border-bottom: 1px solid black;
        }
       .d {
            width: 100%;
            height: 100px;
            color: white;
            background-color: blue;
            font-size: 50px;
            text-align: center;
            margin-bottom: 20px;
            border-bottom: 1px solid black;
        }
        #postsTable tr td {
            width: 25%;
        }
    </style>
</head>
<body>
    <h2 class="d">Blog Management System</h2>
    <table id="postsTable">
        <tr>
            <th>ID</th>
            <th>User ID</th>
            <th>Body</th>
            <th>Title</th>
        </tr>
    </table>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $.ajax({
            url: 'https://jsonplaceholder.typicode.com/posts',
            type: 'GET',
            success: function (response) {
                console.log('Response:', response);
                let list = response;
                list.forEach(item => {
                    console.log(item);
                    $("#postsTable").append(
                        "<tr>" +
                        "<td>" + item.id + "</td>" +
                        "<td>" + item.userId + "</td>" +
                        "<td>" + item.body + "</td>" +
                        "<td>" + item.title + "</td>" +
                        "</tr>"
                    );
                });
            },
            error: function (xhr, status, error) {
                console.error("An error occurred: " + error);
            }
        });
    </script>
</body>
</html>
